<template>
    <div >
        <Button type="primary" @click="addMessage">添加</Button>
        <Button type="error" @click="removes">删除多个</Button>
        <Layout>
            <Sider hide-trigger :style="{background: '#fff'}">
                
                    <Tree :data="tree" @on-select-change="onSelectChange"></Tree>
            </Sider>
            <Upload
                multiple
                type="drag"
                name='avatar'
                action="http://localhost:3000/upload/data">
                <div style="padding: 20px 0">
                    <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
                    <p>点击图片上传</p>
                </div>
            </Upload>
            <Layout :style="{padding: '0 24px 24px'}">
                 <Table border ref="selection" @on-selection-change="onSelectionChange" :columns="columns" :data="data"></Table>
                 <page :total = "total" :page-size="filter.rows" :page-size-opts="[5,10,15,20]" @on-page-size-change="onPagesizeChange" @on-change="onPage" show-sizer></page>
            </Layout>
        </Layout>
    </div>
</template>

<script>
    import {dataMixins}  from '../common/dataMixins';
    export default{
        mixins : [dataMixins], 
              
        data(){
            return{
                modules:'upload',
                type:3, 
                formValidate: {
                    filename:''
                },
                ruleValidate: {
                    filename: [
                        { required: true, message: 'The title cannot be empty', trigger: 'blur' }
                    ]
                },
                columns: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '链接',
                        key: 'filename',
                        render: (h, params) => {
                            return h('div', [
                                h('Icon', {
                                    props: {
                                        type: 'usb'
                                    }
                                }),
                                h('strong', params.row.filename)
                            ]);
                        }
                    },
                    {
                        title: '操作',
                        key: 'action',
                        width: 180,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.editIdata(params.row._id)
                                        }
                                    }
                                }, '修改'),
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            
                                            this.remove(params.row._id)
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    }
                ]
            }
        }
    }
</script>

<style>

</style>


